package com.shy.dao;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import org.springframework.stereotype.Component;

import com.shy.entity.User;
import com.shy.util.RandomName;

@Component
public class UserRepository {
	private List<User> userList = new ArrayList<> ();

	{
		User user;
		for (int i = 1; i <= 20; i++) {
			user = new User(i, RandomName.randomName(true, 3), i % 2);
			userList.add(user);
		}
	}

	public Optional<User> findById(Integer id) {
		return Optional.ofNullable(userList.get(id));
	}

	public List<User> findAll() {
		return userList;
	}
}
